' QrForm    - Extension of QForm with rounded edges
'
' NEW PROPERTIES:
'    RndX    - Amount of horizontal rounding
'    RndY    - Amount of vertical rounding

$APPTYPE GUI
$INCLUDE "RAPIDQ.INC"

Declare Function CreateRoundRectRgn Lib "gdi32" Alias "CreateRoundRectRgn" _
    (X1 As Long, Y1 As Long, X2 As Long, Y2 As Long, _
    X3 As Long, Y3 As Long) As Long 
Declare Function SetWindowRgn Lib "user32" Alias "SetWindowRgn" _
    (hwnd As Long, hRgn As Long, bRedraw As Long) As Long
Declare Function DeleteObject Lib "gdi32" Alias "DeleteObject" _
    (hObject As Long) As Long
    
TYPE QrForm EXTENDS QForm
    QfRegion AS Long
    RndX AS Long
    RndY AS Long

    EVENT OnShow
        WITH QrForm
            QfRegion=CreateRoundRectRgn(0,0,.Width,.Height,.RndX,.RndY)
            SetWindowRgn .handle,QfRegion,True
        END WITH
    END EVENT
    
    EVENT OnClose
        DeleteObject QfRegion
    END EVENT
    
    CONSTRUCTOR
        RndX=30
        RndY=30
    END CONSTRUCTOR
END TYPE

' Test QrForm component

CREATE Form AS QrForm
    'BorderStyle=bsDialog
    Caption="   QForm with rounded edges"
    
    ShowModal
END CREATE


